<?php /* Smarty version 2.6.14, created on 2015-01-13 17:50:17
         compiled from file_upload.recharge.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<!--<link href="<?php echo @BASEURI; ?>
templates/images/upload.css" rel="stylesheet" type="text/css">-->
</head>

<body>
<?php if ($this->_tpl_vars['post']): ?>
<script language="javascript">
    parent.document.getElementById('<?php echo $this->_tpl_vars['inputid']; ?>
').value='<?php echo $this->_tpl_vars['path']; ?>
';
    <?php if ($this->_tpl_vars['thumbEle']): ?>parent.document.getElementById('<?php echo $this->_tpl_vars['thumbEle']; ?>
').value='<?php echo $this->_tpl_vars['thumb_file']; ?>
';<?php endif; ?>
    parent.offDialog();
</script>
<?php else: ?>
    <script>
    function checkPic(){
        var uploadfile=document.getElementById("uploadfile").value;
        var type=uploadfile.substring(uploadfile.lastIndexOf(".")+1,uploadfile.length).toLowerCase();
        if(type!="jpg"&&type!="bmp"&&type!="gif"&&type!="png"){
            resetFile();//清空file控件内容
            alert("<?php echo $this->_tpl_vars['systemLang']['uploadRightFormat']; ?>
");
            return false;
        }
        document.getElementById("Preview").style.display="block";
        return true;
    }
    //图片预览
    function PreviewImage(divImage,upload,width,height) {
        if(checkPic()){
            try{
                var imgPath;
                //图片路径
                var Browser_Agent=navigator.userAgent;
                //判断浏览器的类型
                if(Browser_Agent.indexOf("Firefox")!=-1){
                    //火狐浏览器
                    //imgPath = upload.files[0].getAsDataURL();
                        var file = document.getElementById('uploadfile').files[0];
                        try{ //火狐7.0以后
                        imgPath =window.URL.createObjectURL(file);
                        }catch (e){
                        imgPath =file.getAsDataURL();
                        }
                        document.getElementById(divImage).innerHTML = "<img id='imgPreview' src='"+imgPath+"' width='"+width+"' height='"+height+"'/>";
                }else{
                    //IE浏览器
                    var Preview = document.getElementById(divImage);
                    Preview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = upload.value;
                    Preview.style.width = width;
                    Preview.style.height = height;
                }
            }catch(e){
                resetFile();//清空file控件内容
                alert("<?php echo $this->_tpl_vars['systemLang']['uploadRightFormat']; ?>
");
            }
        }
    }

    /*以下代码主要用来当用户选择了非指定类型图片时清空上传控件的值*/
    //var html=document.getElementById("Preview").innerHTML;
    function resetFile(){
      //  document.getElementById("Preview").style.display="none";//隐藏显示选中图片的层
      //  document.getElementById("Preview").innerHTML=html; //清空file控件
    }
    </script>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="<?php echo @BASEURI; ?>
file_upload/recharge">
  <label>
  <input type="hidden" name="inputid" value="<?php echo $this->_tpl_vars['inputid']; ?>
" />
  <input type="hidden" name="size" value="<?php echo $this->_tpl_vars['size']; ?>
" />
  <input type="hidden" name="thumb_id" value="<?php echo $this->_tpl_vars['get_thumb_id']; ?>
" />
  <input type="file" name="uploadfile" id="uploadfile" onchange="PreviewImage('Preview',this,100,90);" /><br/>
 <!-- 生成缩略图:<input type="checkbox" name="isThumb" value="1">&nbsp;&nbsp;X<input type="text" name="width" value="200" size="5"/> Y<input type="text" name="height" value="200" size="5"/><br/>-->
  <input type="submit" name="button" id="button" value="<?php echo $this->_tpl_vars['systemLang']['upload']; ?>
" class="button" />
  <div id="Preview" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);">
                &nbsp;</div>
  </label>
</form>
<?php endif; ?>
</body>
</html>